public class GreenfootSound extends java.lang.Object Represents audio that can be played in Greenfoot. A GreenfootSound loads the audio from a file. The sound cannot be played several times simultaneously, but can be played several times sequentially. Most files of the following formats are supported: AIFF, AU, WAV, MP3 and MIDI.
Version:
2.1
Author:
Poul Henriksen 保罗 亨里克森
构造方法
Constructor Summary GreenfootSound(java.lang.String filename)
Creates a new sound from the given file.
其他方法
Method Summary boolean isPlaying()
True if the sound is currently playing.
void pause()
Pauses the current sound if it is currently playing.
void play()
Start playing this sound.
void playLoop() 循环播放
Play this sound repeatedly in a loop.
void stop()
Stop playing this sound if it is currently playing.
java.lang.String toString()
Returns a string representation of this sound containing the name of the file and whether it is currently playing or not.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
这个类的功能比较简单,,,,,不过能扩展啊!
Constructor Detail
GreenfootSound
public GreenfootSound(java.lang.String filename)Creates a new sound from the given file.
Parameters:
filename - Typically the name of a file in the sounds directory in the project directory.
Method Detail
play
public void play()Start playing this sound. If it is playing already, it will do nothing. If the sound is currently looping, it will finish the current loop and stop. If the sound is currently paused, it will resume playback from the point where it was paused. The sound will be played once.
playLoop
public void playLoop()Play this sound repeatedly in a loop. If called on an already looping sound, it will do nothing. If the sound is already playing once, it will start looping instead. If the sound is currently paused, it will resume playing from the point where it was paused.
stop
public void stop()Stop playing this sound if it is currently playing. If the sound is played again later, it will start playing from the beginning. If the sound is currently paused it will now be stopped instead.
pause
public void pause()Pauses the current sound if it is currently playing. If the sound is played again later, it will resume from the point where it was paused.
Make sure that this is really the method you want. If possible, you should always use stop(), because the resources can be released after calling stop(). The resources for the sound will not be released while it is paused.
See Also:
stop()
isPlaying
public boolean isPlaying()True if the sound is currently playing.
toString
public java.lang.String toString()Returns a string representation of this sound containing the name of the file and whether it is currently playing or not.
greenfoot Class GreenfootSound
java.lang.Objectgreenfoot.GreenfootSound
关于背景音乐和Actor音乐等发声装置的类
public class GreenfootSound extends java.lang.Object Represents audio that can be played in Greenfoot. A GreenfootSound loads the audio from a file. The sound cannot be played several times simultaneously, but can be played several times sequentially. Most files of the following formats are supported: AIFF, AU, WAV, MP3 and MIDI.
Version:
2.1
Author:
Poul Henriksen 保罗 亨里克森
构造方法
Constructor Summary
GreenfootSound(java.lang.String filename)
Creates a new sound from the given file.
其他方法
Method Summary
boolean isPlaying()
True if the sound is currently playing.
void pause()
Pauses the current sound if it is currently playing.
void play()
Start playing this sound.
void playLoop() 循环播放
Play this sound repeatedly in a loop.
void stop()
Stop playing this sound if it is currently playing.
java.lang.String toString()
Returns a string representation of this sound containing the name of the file and whether it is currently playing or not.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
这个类的功能比较简单,,,,,不过能扩展啊!
Constructor Detail
GreenfootSound
public GreenfootSound(java.lang.String filename)Creates a new sound from the given file.
Parameters:
filename - Typically the name of a file in the sounds directory in the project directory.
Method Detail
play
public void play()Start playing this sound. If it is playing already, it will do nothing. If the sound is currently looping, it will finish the current loop and stop. If the sound is currently paused, it will resume playback from the point where it was paused. The sound will be played once.
playLoop
public void playLoop()Play this sound repeatedly in a loop. If called on an already looping sound, it will do nothing. If the sound is already playing once, it will start looping instead. If the sound is currently paused, it will resume playing from the point where it was paused.
stop
public void stop()Stop playing this sound if it is currently playing. If the sound is played again later, it will start playing from the beginning. If the sound is currently paused it will now be stopped instead.
pause
public void pause()Pauses the current sound if it is currently playing. If the sound is played again later, it will resume from the point where it was paused.
Make sure that this is really the method you want. If possible, you should always use stop(), because the resources can be released after calling stop(). The resources for the sound will not be released while it is paused.
See Also:
stop()
isPlaying
public boolean isPlaying()True if the sound is currently playing.
toString
public java.lang.String toString()Returns a string representation of this sound containing the name of the file and whether it is currently playing or not.
Overrides:
toString in class java.lang.Object